package org.sjs.dreamfly.player

import android.annotation.SuppressLint
import android.content.Intent
import android.content.pm.ActivityInfo
import android.os.Bundle
import android.view.Window
import android.view.WindowManager
import org.sjs.dreamfly.R
import org.sjs.dreamfly.common.base.BaseActivity
import org.sjs.dreamfly.common.util.Router
import org.sjs.dreamfly.model.VideoInfo


class PlayerActivity : BaseActivity(), IPlayerDataProvider {

    override fun onCreate(savedInstanceState: Bundle?) {
        if (intent.getIntExtra(Router.KEY_ORIENTATION, Router.ORIENTATION_PORTRAIT) == Router.ORIENTATION_LANDSCAPE) {
            requestWindowFeature(Window.FEATURE_NO_TITLE)
            requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE
        }
        super.onCreate(savedInstanceState)
        window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN)
    }

    override fun requireLayoutId(): Int {
        return R.layout.activity_player
    }

    override fun onBindViews() {}

    override fun onInitViews() {
        hideTitleBar()
    }

    @SuppressLint("MissingSuperCall")
    override fun onNewIntent(intent: Intent?) {
    }

    override fun onLoadData(savedInstanceState: Bundle?, newIntent: Intent?) {
        if (savedInstanceState == null) {
            supportFragmentManager.beginTransaction()
                .replace(R.id.container, PlayerFragment.newInstance<MoviePlayerFragment>(0))
                .commitNow()
        }
    }

    override fun getVideoList(): MutableList<VideoInfo> {
        // TODO: 没有数据准备逻辑
        return mutableListOf()
    }
}